/*
 * SafeArray.h
 *
 *  Created on: 2014. 4. 24.
 *      Author: zenoniaonline
 */

#ifndef PROJECTZ_NUTIL_SAFEARRAY_H_
#define PROJECTZ_NUTIL_SAFEARRAY_H_

#include <array>

namespace ProjectZ { namespace NUtil {

template<class Type, int size>
class SafeArray
{
private:
	std::array<Type, size> _clsArray;

public:
	void Initialize(int init_value)
	{
		for (int index = 0; index < this->max_size(); index++)
		{
			if (false == this->SetValue(index, init_value))
			{
				DEBUGLOG("SAFEARRAY ERROR INDEX : %d, VALUE : %d", index, init_value);
				break;
			}
		}
	}


	bool SetValue(int index, int value)
	{
		if (index < 0) return false;
		if (index >= this->max_size()) return false;

		_clsArray[index] = value;
		return true;
	}

	bool GetValue(int index, Type & value)
	{
		if (index < 0) return false;
		if (index >= this->max_size()) return false;

		value = _clsArray[index];
		return true;
	}

	int max_size() { return _clsArray.max_size(); }
	//int size() { return static_cast<int>(_clsArray.size()); }
};

} /*NUtil*/ } /*ProjectZ*/

#endif /* PROJECTZ_NUTIL_SAFEARRAY_H_ */
